const app = getApp()

Page({
  data: {
    loading: true,
    page: 0,
    card: [],
  },
  //监听页面初次载入完成
  onLoad: function (event) {
    this.getCard();
  },
  //上拉加载
  onReachBottom: function () {
    this.setData({
      loading: true,
    });
    this.getCard();
  },
  //获取API
  getCard: function () {
    if (this.data.loading) {
      var parms = {
        page: this.data.page + 1,
      }
      app.api().Get('api/v1/bestbao/card/engineerNotMe', parms, (result) => {
        if (result.code == 200) {
          var card = this.data.card;
          for (let i in result.data) {
            card.push(result.data[i]);
          }
          this.setData({
            card: card,
            page: parms.page,
          });
        }
      })
      this.setData({
        loading: false,
      });
    }
  },
  //选择工程师
  selectCard: function (event) {
    let pages = getCurrentPages();
    let prevPage = pages[pages.length - 2];
    prevPage.setData({
      change_engineer: event.currentTarget.dataset.name,
      change_id: event.currentTarget.dataset.id,
    })
    wx.navigateBack({
      delta: 1,
    })
  }
})